package com.atguigu.gmall.common.util;


import javax.servlet.http.HttpServletRequest;


 /**
 * @author: atguigu
 * @create: 2023-01-11 10:31
 */
public class AuthContextHolder {


    /**
     * 从请求对象中获取用户ID
     *
     * @return
     */
    public static String getUserId(HttpServletRequest request) {
        String userId = request.getHeader("userId");
        return org.apache.commons.lang.StringUtils.isNotBlank(userId) ? userId : "";
    }


    /**
     * 从请求对象中获取临时用户ID
     *
     * @return
     */
    public static String getUserTempId(HttpServletRequest request) {
        String userTempId = request.getHeader("userTempId");
        return org.apache.commons.lang.StringUtils.isNotBlank(userTempId) ? userTempId : "";
    }
}
